/*
 * carrot.c
 *
 *  Created on: Sep 7, 2013
 *      Author: Joseph DeLong
 */

#include <ctype.h>

char value[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
int worth[26] = {-10,-5,5,0,-1,-2,10,-11,25,15,18,-7,-4,3,1,-4,13,-17,13,8,-4,-9,-2,7,1,3};

/*
 * CARROT function
 * Allows the user to feed the friendly Appaloosa. In return, she will accept any name you give her.
 * parameter QUALITY: A character representing the quality of the carrot offered to Appaloosa. Quality values are:
 *
 * 		VALUE		    	| QUALITY POINTS
 * 		--------------------|---------------
 * 		A(awful)	    	|	-10
 * 		B(bitter)			|	-5
 * 		C(crisp)			|	+5
 * 		D(dirty)			|	0
 * 		E(erroneous)	    |	-1
 * 		F(flimsy)	    	|	-2
 * 		G(good)		    	|	+10
 * 		H(horrible)	    	|	-11
 * 		I(ideal)	    	|	+25
 * 		J(just right)	    |	+15
 * 		K(killer)	    	|	+18
 * 		L(lousy)	    	|	-7
 * 		M(moldy)	    	|	-4
 * 		N(normal)	    	|	+3
 * 		O(orange)	    	|	+1
 * 		P(poor)		    	|	-4
 * 		Q(quick)	    	|	+13
 * 		R(rotten)	    	|	-17
 * 		S(sweet)	    	|	+13
 * 		T(tasty)	    	|	+8
 * 		U(ugly)		    	|	-4
 * 		V(violent)	    	|	-9
 * 		W(wobbly)	    	|	-2
 * 		X(x-ray)	    	|	+7
 * 		Y(yellow)	    	|	+1
 * 		Z(zebra)	    	|	+3
 *
 * parameter QUANTITY: Integer representing the number of carrots offered to old faithful Appaloosa.
 * returns: Pointer to character string containing the new name Appaloosa accepts commands by.
 */
char *carrot(char quality, int quantity) {
	char returnVal[10];
	int i;
	for(i = 0; i < 26; i++) {
		if(value[i] == toupper(quality)) {
			if((worth[i] * quantity) >= 100) {
				//allow change
				printf("Appaloosa accepts your gracious gift of CARROT. What should her new PROMPT be? (Maximum of 10 characters)\n");
				i = sizeof(returnVal);
				sys_req(1,1, returnVal, &i); //get input form user
			}
			else {
				//disallow change
				printf("Appaloosa turns her head away. Your gift of CARROT is sub-par at best.\n");
			}
		}
		else {
			//improper quality...must be A-Z
			printf("Appaloosa paws nervously in the dirt. Your gift of CARROT is unrecognizable.\n");
		}
	}
	return &returnVal;
}//have a nice day!
